﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain.Core
{
    /// <summary>
    /// 实体基类
    /// </summary>
    public abstract class EntityBase : INotifyPropertyChange
    {
        /// <summary>
        /// 得到枚举对象的Description特性的值
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        protected string GetDescription(Enum obj)
        {
            return obj.GetDescription();
        }

        /// <summary>
        /// 触发PropertyChanging事件
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        protected virtual void SendPropertyChanging(String propertyName, object propertyValue)
        {
            if ((this.PropertyChanging != null))
            {
                this.PropertyChanging(this, new PropertyChangeEventArgs(propertyName, propertyValue));
            }
        }

        /// <summary>
        /// 触发PropertyChanged事件
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        protected virtual void SendPropertyChanged(String propertyName, object propertyValue)
        {
            if ((this.PropertyChanged != null))
            {
                this.PropertyChanged(this, new PropertyChangeEventArgs(propertyName, propertyValue));
            }
        }

        /// <summary>
        /// 属性修改之前的事件
        /// </summary>
        public event PropertyChangeEventHandler PropertyChanging;

        /// <summary>
        /// 属性修改之后的事件
        /// </summary>
        public event PropertyChangeEventHandler PropertyChanged;
    }
}
